package com.interest.business.service.impl;

import java.util.List;

import com.hy.corecode.idgen.WFGIdGenerator;
import com.interest.business.domain.vo.GoodVo;
import com.interest.common.utils.DateUtils;
import com.interest.common.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.interest.business.mapper.InterestGoodsMapper;
import com.interest.business.domain.InterestGoods;
import com.interest.business.service.IInterestGoodsService;

/**
 * 商品Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-03-23
 */
@Service
public class InterestGoodsServiceImpl implements IInterestGoodsService 
{
    @Autowired
    private InterestGoodsMapper interestGoodsMapper;

    @Autowired
    WFGIdGenerator wfgIdGenerator;

    /**
     * 查询商品
     * 
     * @param id 商品主键
     * @return 商品
     */
    @Override
    public InterestGoods selectInterestGoodsById(String id)
    {
        return interestGoodsMapper.selectInterestGoodsById(id);
    }

    /**
     * 查询商品列表
     * 
     * @param interestGoods 商品
     * @return 商品
     */
    @Override
    public List<GoodVo> selectInterestGoodsList(GoodVo interestGoods)
    {
        return interestGoodsMapper.selectInterestGoodsList(interestGoods);
    }

    /**
     * 新增商品
     * 
     * @param interestGoods 商品
     * @return 结果
     */
    @Override
    public int insertInterestGoods(InterestGoods interestGoods)
    {
        interestGoods.setId(IdUtils.simpleUUID());
        interestGoods.setCreateTime(DateUtils.getNowDate());
        interestGoods.setCode("PD"+wfgIdGenerator.next());
        return interestGoodsMapper.insertInterestGoods(interestGoods);
    }

    /**
     * 修改商品
     * 
     * @param interestGoods 商品
     * @return 结果
     */
    @Override
    public int updateInterestGoods(InterestGoods interestGoods)
    {
        return interestGoodsMapper.updateInterestGoods(interestGoods);
    }

    /**
     * 批量删除商品
     * 
     * @param ids 需要删除的商品主键
     * @return 结果
     */
    @Override
    public int deleteInterestGoodsByIds(String[] ids)
    {
        return interestGoodsMapper.deleteInterestGoodsByIds(ids);
    }

    /**
     * 删除商品信息
     * 
     * @param id 商品主键
     * @return 结果
     */
    @Override
    public int deleteInterestGoodsById(String id)
    {
        return interestGoodsMapper.deleteInterestGoodsById(id);
    }
}
